#pragma once
#include "cocos2d.h"
#include "cocos-ext.h"
#include "Player.h"
#include "CommonUtil.h"
USING_NS_CC;
USING_NS_CC_EXT;
using namespace gui;
class BattleScene:public CCScene
{
public:

	BattleScene()
	{
	}
	~BattleScene()
	{
	}
	void setPlayer(Player* me){
		//this->me=me;
	}

private :
	
	void touchEvent(CCObject* pSender,cocos2d::gui::TouchEventType type){
        Player *me=CommonUtil::getInstance()->getPlayer();
		UIButton*  button=(UIButton*)pSender;
		switch(type){
            case TOUCH_EVENT_BEGAN:{
			if(strcmp(button->getName(),"left")==0){
                me->setState(XRUN);
				me->setDirection(LEFT);
			}else if(strcmp(button->getName(),"right")==0){
				me->setState(XRUN);
				me->setDirection(RIGHT);
			}else if(strcmp(button->getName(),"up")==0){
				me->setState(YRUN);
				me->setDirection(UP);
			}else if(strcmp(button->getName(),"down")==0){
				me->setState(YRUN);
				me->setDirection(DOWN);
			}
			MoveMessage* msg=new MoveMessage(me->getName(),me->getPosition().x,me->getPosition().y);
			me->send(msg);
            }
			break;
		case TOUCH_EVENT_ENDED:
			me->setState(STAND);
			break;
		}
	}
};

